package com.tju.shortlink.project.controller;

import com.tju.shortlink.project.service.ILinkService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Tag(name = "短链接跳转相关接口")
@RestController
@RequiredArgsConstructor
public class LinkJumpController {


    private final ILinkService linkService;

    @Operation(summary = "短链接跳转")
    @GetMapping("{short-uri}")
    public void restoreUrl(@PathVariable("short-uri") String shortUri, HttpServletRequest request, HttpServletResponse response) throws IOException {
        linkService.restoreUrl(shortUri, request, response);
    }

}
